// 项目地址：https://github.com/hspprogrammer/wxminiSharedData

var t = { d: (e, o) => { for (var n in o) t.o(o, n) && !t.o(e, n) && Object.defineProperty(e, n, { enumerable: !0, get: o[n] }) }, o: (t, e) => Object.prototype.hasOwnProperty.call(t, e) },
    e = {};
t.d(e, { Ay: () => U, QZ: () => D, ii: () => W, gk: () => L, Jv: () => C, IX: () => R, k2: () => T });
let o = !0;
const n = {};
["includes", "indexOf", "lastIndexOf"].forEach((t => {
    const e = Array.prototype[t];
    n[t] = function(...t) { let o = e.apply(this, t); return !1 === o && (o = e.apply(this[p], t)), o }
})), ["push", "pop", "shift", "unshift", "splice"].forEach((t => {
    const e = Array
        .prototype[t];
    n[t] = function(...t) { o = !1; for (let e = 0; e < t.length; e++) t[e] = t[e][p] || t[e]; let n = e.apply(this, t); return o = !0, n }
}));
const s = {
    add(t) {
        const e = this[p],
            o = t[p] || t,
            n = e.has(o),
            s = e.add(o);
        return n || b(e, t, i.ADD), s
    },
    delete(t) {
        const e = this[p],
            o = e.has(t),
            n = e.delete(t);
        return o && b(e, t, i.DEL), n
    },
    get(t) {
        const e = this[p],
            o = e.has(t);
        if (E(e, t), o) { const o = e.get(t); return "object" == typeof o ? v(o) : o }
    },
    set(t, e) {
        const o = this[p],
            n = o.has(t),
            s = o.get(t),
            r = e[p] || e;
        o.set(t, r), n ? s !== e && s == s && e == e && b(o, t, i.SET) : b(o, t, i.ADD)
    },
    forEach(t, e) {
        const o = this[p];
        E(o, f);
        const n = t => "object" == typeof t && null !== t ? v(t) : t;
        o.forEach(((o, s) => { t.call(e, n(o), n(s), this) }))
    },
    [Symbol.iterator]: r(),
    entries: r(),
    values: r(2),
    keys: r(3)
};

function r(t = 1) {
    return () => {
        const e = this[p],
            o = e[Symbol.iterator](),
            n = t => "object" == typeof t && null !== t ? v(t) : t;
        return E(e, 3 === t ? u : f), {
            next() {
                const { value: e, done: s } = o.next();
                return 1 === t ? {
                    value: e ? [n(e[0]), n[e[
                        1]]] : e,
                    done: s
                } : 2 === t ? { value: e ? n(e[0]) : e, done: s } : 3 === t ? { value: n(e), done: s } : void 0
            },
            [Symbol.iterator]() { return this }
        }
    }
}

function a(t, e) {
    if (typeof t != typeof e) return !1;
    if ("object" != typeof t || null === t || null === e) return t === e;
    const o = Object.keys(t),
        n = Object.keys(e);
    if (o.length !== n.length) return !1;
    for (let n of o)
        if (!a(t[n], e[n])) return !1;
    return !0
}
let c = 1;
var i;
! function(t) { t.SET = "SET", t.ADD = "ADD", t.DEL = "DEL" }(i || (i = {}));
const l = new Map,
    f = Symbol(),
    u = Symbol(),
    p = Symbol(),
    h = new WeakMap,
    d = new WeakMap,
    y = new WeakMap,
    g = [];
let m = null;

function D(t, e) {
    const o = () => { S(o), m = o, g.push(o), t(), g.pop(), m = g[g.length - 1] };
    o.options = e || { lazy: !0 }, o.deps = [];
    const n = getCurrentPages()[0];
    o.page = n, o._id = c, c++;
    let s = d.get(this);
    s || this && d.set(this, s = []), s && s.push(o), e && e.scheduler ? e.scheduler(o) : o()
}

function S(t) {
    for (let e = 0; e < t.deps.length; e++) t.deps[e].delete(t);
    t.deps.length = 0
}

function w() {
    let t = d.get(this) || [];
    for (let e = 0; e < t.length; e++) S(t[e]);
    t.length = 0
}

function A(t, e = !1) {
    return new Proxy(t, {
        get(t, o, r) {
            if (o === p) return t;
            if (t instanceof Set || t instanceof WeakSet || t instanceof Map || t instanceof WeakMap) return "size" === o ? (E(
                t, f), Reflect.get(t, o, t)) : s[o] || t[o].bind(t);
            if (Array.isArray(t) && n.hasOwnProperty(o)) return Reflect.get(n, o, r);
            const a = Reflect.get(t, o,
                r);
            return "symbol" != typeof o && E(t, o), e ? a : "object" == typeof a && null !== a ? v(a) : a
        },
        set(t, e, o, n) {
            const s = t[e],
                r = Array.isArray(t) ? Number(e) < t.length ? i.SET : i.ADD : Object.prototype.hasOwnProperty.call(t, e) ? i.SET : i.ADD;
            o = o[p] || o;
            const c = Reflect.set(t, e, o, n);
            t === n[p] && (a(o, s) || s != s && o != o || b(t, e, r, o));
            const l = O[e];
            return l && l.forEach(((t, e) => {
                const n = {};
                t.forEach((t => { n[t] = o })), e.setData(n)
            })), c
        },
        has: (t, e) => (E(t, e), Reflect.has(t, e)),
        ownKeys: t => (E(t, Array.isArray(t) ? "length" : f), Reflect.ownKeys(t)),
        deleteProperty(t, e) {
            const o = Object.prototype.hasOwnProperty.call(t, e),
                n = Reflect.deleteProperty(t, e);
            return n && o && b(t, e, i.DEL, Number.MAX_SAFE_INTEGER), n
        }
    })
}

function E(t, e) {
    if (!m || !o) return;
    let n = h.get(t);
    n || h.set(t, n = new Map);
    let s = n.get(e);
    s || n.set(e, s = new Set), s.add(m), m.deps.push(s)
}

function b(t, e, o, n) {
    let s = h.get(t);
    if (!s) return !0;
    const r = s.get(e),
        a = new Set;
    if (r && r.forEach((t => { t != m && a.add(t) })), o === i.ADD || o === i.DEL || o === i.SET && (t instanceof Map || t instanceof WeakMap)) {
        const t = s.get(f);
        t && t.forEach((t => { t != m && a.add(t) }))
    }
    if (o === i.ADD || o === i.DEL || t instanceof Map || t instanceof WeakMap) {
        const t = s.get(u);
        t && t.forEach((t => { t != m && a.add(t) }))
    }
    if (o === i.ADD && Array.isArray(t)) {
        const t = s.get("length");
        t && t.forEach((t => { t != m && a.add(t) }))
    }
    Array.isArray(t) && "length" === e && s.forEach(((t, e) => { e >= n && t.forEach((t => { t != m && a.add(t) })) }));
    const c =
        getCurrentPages(),
        l = c[c.length - 1];
    a && a.forEach((t => {
        var e, o;
        if (t.options.lazy)
            if (t.page === l)(null === (e = t.options) || void 0 === e ? void 0 : e.scheduler) ? t.options.scheduler(t) : t();
            else {
                let e = y.get(t.page);
                e || y.set(t.page, e = new Set), e.add(t)
            }
        else(null === (o = t.options) || void 0 === o ? void 0 : o.scheduler) ? t.options.scheduler(t) : t()
    }))
}

function v(t) { const e = l.get(t); if (e) return e; const o = A(t); return l.set(t, o), o }
const O = {};
let P = {},
    $ = {},
    j = {},
    k = {},
    M = {};

function L(t) {
    let e = {};
    for (const o in t)
        if (Object.hasOwnProperty.call(t, o)) {
            const n = t[o].split(".")[0];
            let s = O[n];
            s || (s = new Map, s.set(this, new Set)), s.has(this) || s.set(this, new Set), s.get(this).add(o), O[n] = s, $ && null != $[n] && (e[o] = $[n])
        } this.setData(e)
}

function T(t) { return j[t]() }

function C() {
    const t = arguments[0];
    if (!t) return console.error("请输入store的mutations名称");
    if (k[t]) {
        const e = t.split("/");
        e.pop(), arguments[0] = e.length ? e.reduce(((t, e) => t[e]), $) : $, k[t].apply(this, [...arguments])
    } else console.error(`未找到${t},请输入store正确的mutations`)
}

function R(t) {
    if (!t) return console.error("请输入store的actions名称");
    if (M[t]) {
        const e = t.split("/");
        e.pop(), arguments[0] = { storeCommit: C, StoreData: e.length ? e.reduce(((t, e) => t[e]), $) : $ }, M[t].apply(this, [...arguments])
    } else console.error(`未找到${t},请输入store正确的actions`)
}

function x() {
    if ($)
        for (const t in $) Object.hasOwnProperty.call($, t) && O[t] && O[t].has(this) && O[t].delete(this)
}

function W() { return $ }
var G, I;
G = Page, Page = function(t) {
    t.$setStoreToPage = L, t.$storeCommit = C, t.$storeDispatch = R, t.$effect = D, t.$getStoreData = W, t.$storeGetters = T, t.onLoad || (t.onLoad = function() {}), t
        .onShow || (t.onShow = function() {});
    var e = t.onLoad;
    t.onLoad = function() { return this.$storeData = W(), e.apply(this, Array.prototype.slice.call(arguments)) };
    var o = t.onShow;
    t.onShow = function() {
        return function() {
            const t = getCurrentPages()[0];
            [...y.get(t) || []].forEach((t => {
                var e;
                (null === (e = t.options) || void 0 === e ? void 0 : e.scheduler) ? t.options.scheduler(t): t()
            }))
        }(), o.apply(this, Array.prototype.slice.call(arguments))
    }, t.onUnload || (
        t.onUnload = function() {});
    var n = t.onUnload;
    t.onUnload = function() { return x.call(this), w.call(this), n.apply(this, Array.prototype.slice.call(arguments)) }, G(t)
}, I = Component, Component = function(t) {
    t.methods || (t
            .methods = {}), t.methods.$setStoreToPage = L, t.methods.$storeCommit = C, t.methods.$storeDispatch = R, t.methods.$effect = D, t.methods.$getStoreData = W, t.methods.$storeGetters =
        T, t
        .detached || (t.detached = function() {});
    var e = t.detached;
    t.detached = function() { return x.call(this), w.call(this), e.apply(this, Array.prototype.slice.call(arguments)) }, I(t)
}, console.log("当前wxminiSharedData版本：2.1.1");
const U = function(t) {
    const e = {};
    t.name || (t.name = ""), t.modules || (t.modules = {}), t.data || (t.data = {}), t.getters || (t.getters = {}), t.mutations || (t.mutations = {}), t.actions || (t.actions = {});
    for (const
            e in t.modules) {
        const o = t.modules[e],
            n = o.name || e;
        if (t.data[n] = o.data || null, o.getters)
            for (const e in o.getters) Object.prototype.hasOwnProperty.call(o.getters, e) && (t.getters[`${n}/${e}`] = o.getters[e]);
        if (o.mutations)
            for (const e in o.mutations) Object.prototype.hasOwnProperty.call(o.mutations, e) && (t.mutations[`${n}/${e}`] = o.mutations[e]);
        if (o.actions)
            for (const e in o.actions) Object.prototype.hasOwnProperty.call(o.actions, e) && (t.actions[`${n}/${e}`] = o.actions[e])
    }
    $ = v(t.data), P = t.modules;
    for (const o in t.getters)
        Object.prototype.hasOwnProperty.call(t.getters, o) && (j[o] = () => (e[o] || D((() => { delete e[o], t.getters && (e[o] = t.getters[o]($)) })), e[o]));
    k = t.mutations, M = t.actions
};
var z = e.Ay,
    N = e.QZ,
    X = e.ii,
    _ = e.gk,
    J = e.Jv,
    K = e.IX,
    Q = e.k2;
export { z as default, N as effect, X as getStoreData, _ as setStoreToPage, J as storeCommit, K as storeDispatch, Q as storeGetters };